package com.numberma.loggingservice.rabbitmq;


import com.numberma.loggingservice.Service.LoggingService;
import com.numberma.loggingservice.entity.Log;
import com.numberma.loggingservice.mapper.LoggingMapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.core.ExchangeTypes;
import org.springframework.amqp.rabbit.annotation.Exchange;
import org.springframework.amqp.rabbit.annotation.Queue;
import org.springframework.amqp.rabbit.annotation.QueueBinding;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
@Slf4j
@Component
public class LoggingConsumer {
    @Autowired
    private LoggingMapper loggingMapper;



    @RabbitListener(bindings = @QueueBinding(
            value = @Queue(name = "Logging.queue"),
            exchange = @Exchange(name = "Log.exchange", type = ExchangeTypes.DIRECT),
            key = "Logging.queue"
    ))
    public void insertUser(Log logs) {
        //写入数据表
        log.info("写入数据表");
        loggingMapper.insert(logs);
           
    }





}
